package org.geektimes.http.server.jdk.servlet.demo;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author wenl
 */
@WebServlet(name = "antPathServlet", urlPatterns = {
        "/ant*"
})
public class AntPathServlet extends HttpServlet {

    @Override
    public void service( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String content = " ant path matcher is OK ";
        response.setStatus(HttpServletResponse.SC_OK);
        response.setContentLength(content.length());
        ServletOutputStream outputStream = response.getOutputStream();
        outputStream.write(content.getBytes(StandardCharsets.UTF_8));
        outputStream.flush();
    }
}
